﻿<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta name="renderer" content="webkit">
    <link href="/LiberUI/Style/LiberUI.css" rel="stylesheet" />
    <link href="/SiteUI/Base.css" rel="stylesheet" />
    <script src="/LiberUI/Scripts/jquery.js"></script>
    <script src="/LiberUI/Scripts/LiberUI.Base.js"></script>
    <script src="/LiberUI/Scripts/LiberUI.Action.js"></script>
    <script src="/LiberUI/Scripts/LiberUI.js"></script>
    <link href="/SiteUI/level2.css" rel="stylesheet" />
    <script src="/SiteUI/res_setting.js"></script>
</head>
<body>

    <div class="view" style="height:100%">
        <!--页面头部导航-->
        <div class="row" id="pageHead">
            <div class="col-lg-2" id="logo">
                <a href="/Index.html">
                    <br />
                    &nbsp;
                    <br />
                    &nbsp;
                </a>
            </div>
            <div class="col-lg-1" id="allMenu">
                更多应用
                <i class="soicon icon-navigatenext"></i>
            </div>
            <!--此处加载当前用户自定义的快捷模块入口-->
            <div class="col-lg-6">
                <div id="headNavi">
                    <div id="myDashbord"><a href="/MyBiz/Dashbord">工作桌面</a></div>
                    <ul id="myMenu"></ul>
                </div>
            </div>
            <!--此处加载用户个人菜单-->
            <div class="col-lg-3" id="userBar">
                <ul>
                    <li class="userBar_menu" id="userHead">
                        <img />
                        <a href="/MyBiz/Index">登录</a>
                    </li>
                    <li class="userBar_menu" id="sysAlert">
                        <i class="soicon icon-notifications"></i>
                        <em>0</em>
                    </li>
                    <li>
                        <a class="Lite" target="_self" href="/SoBiz/Loginout"><i class="soicon icon-powersettingsnew"></i>安全退出</a>
                    </li>
                </ul>
            </div>

            <!--浮动内容-->
            <div class="row">
                <div class="col-lg-7 col-lg-offset-2">
                    <div class="row" id="pvFullMenu">
                        <a id="lnkSetMyNavi" class="LinkTo" href="/MyBiz/MyNavi">选择我的常用导航</a>
                    </div>
                </div>
                <div class="col-lg-2 col-lg-offset-9">
                    <div id="pvAcntInfo">
                        <a class="Lite" href="/MyBiz/Index"><i class="soicon icon-accountcircle"></i>个人资料</a>
                        <a class="Lite" href="/MyBiz/MyNavi"><i class="soicon icon-fenlei"></i>我的应用</a>
                        <a class="Lite" href="/MyBiz/MyMessage"><i class="soicon icon-chat"></i>消息中心</a>
                    </div>
                </div>
                <div class="col-lg-4 col-lg-offset-9">
                    <div id="pvMyAlerts">
                        <h4></h4>
                    </div>
                </div>
            </div>
        </div>

        <!--页面主体内容-->
        <div class="row" id="pageContent">
            <!--左侧内容导航栏-->
            <div class="col-lg-2" id="pageLeft">
                <div class="row" id="contentnavi">
                    @RenderSection("contentnavi",false)
                </div>
            </div>
            <!--右侧内容区域-->
            <div class="col-lg-10" id="pageRight">
                <div class="row">
                    @RenderBody()
                </div>

                <!--页脚-->
                <div class="row" id="pageFootV2">
                    <div class="col-lg-5 col-lg-offset-1" id="aboutUs">
                        <a class="Lite" href="/Agreement.html?statement">安全声明</a>
                        <span>|</span>
                        <a class="Lite" href="/Agreement.html?agreement">用户协议</a>
                        <span>|</span>
                        <a class="Lite" href="/AboutUS.html">关于我们</a>
                        <br />
                        <a class="Lite">Copyright © 2014-2018 tlunion.com 版权所有 | By 天联数创</a>
                        <br />
                        <a class="Lite" href="http://www.miitbeian.gov.cn/">粤ICP备16018901号</a>
                    </div>
                    <div class="col-lg-2" id="connactUs">
                        <a class="Lite">工作时间：<label style="font-size:80%">9：00 - 22：00</label></a>
                        <br />
                        <a class="Lite">商务合作：13727028998</a>
                        <br />
                        <a class="Lite">市场推广：18520170858</a>
                    </div>
                    <div class="col-lg-2" id="mailUs">
                        <a class="Lite">客服座机：0756-7237358</a>
                        <br />
                        <a class="Lite">客服手机：18826216770</a>
                        <br />
                        <a class="Lite" target="_blank" href="mailto:help@tlunion.com">客服邮箱：help@tlunion.com</a>
                    </div>
                </div>
            </div>
        </div>

    </div>

    <div id="pageHelper">
        <ul>
            <li id="goTop"></li>
        </ul>
    </div>

    <!--公共页面部件-->
    @RenderPage("/Views/Shared/_common.cshtml")

    <script>
        View = {
            topHeight: 0,
            offsetHeight: 0,
            naviTop: 0,
            PageNavi:null,
            onWndScroll: function (ev) {
                var bst = $("#pageRight").scrollTop();
                if (bst > 400) {
                    $("#goTop").fadeIn();
                }
                else {
                    $("#goTop").fadeOut();
                }
            },
            onWndResize: function (ev) {
                View.topHeight = $("#pageHead").outerHeight();
                View.offsetHeight = $("#comInfo").outerHeight();
                View.naviTop = View.topHeight + View.offsetHeight;
                View.PageNavi = $("#pageNavi");
            },
            onHelp: function (ev) {
                if (ev && ev.currentTarget) {
                    switch (ev.currentTarget.ID()) {
                        case "goTop":
                            $("#pageRight").animate({ scrollTop: 0 }, 'normal');
                            break;
                    }
                }
            },
            getUserInfoEnd: function (rtn) {
                if (rtn.IsPositive) {
                    User = rtn.Data;
                    User.setting = mesh(fullSetting, JSON.parse(User.setting),"Title");
                    if (User.headimg) {
                        $("#userHead>img").attr("src", User.headimg);
                    }
                    $("#userHead>a").vl(User.realname || User.username).attr("src", "/MyBiz/Index");
                    if (User.setting && User.setting.SubSystems) {
                        User.setting.SubSystems.forEach(function (s) {
                            if (s.Items) {
                                s.Items.forEach(function (itm) {
                                    if (itm.Active == true) {
                                        var lnk = $("<li>");
                                        lnk.append($("<a class='Lite'>").attr("href", itm.Url).vl(itm.Title));
                                        lnk.appendTo("#myMenu");
                                    }
                                })
                            }
                        })
                    }

                    $("body").trigger("UserReady");
                }
                else {
                    $("#userHead>a").attr("href", "/Index.html").vl('登录');
                }
            },
            CheckAuthor: function (obj, elm) {
                if (!elm) {
                    elm = $("#pageContent");
                }
                //检查所有需要检查obj-auth的元素
                elm.find("[obj-auth]").each(function () {
                    var e = $(this);
                    var flag = false;
                    var h = e.attr("execute");

                    //首先，根据obj-role检查此元素是否
                    var roles = e.attr("obj-role");
                    if (roles) {
                        roles = roles.split('|');
                        roles.forEach(function (r) {
                            if (obj[r] && obj[r].idstr === User.idstr) {
                                flag = true;
                            }
                        })
                    }

                    //如果检查没通过，或者没有指定obj-role
                    //如果指定了obj-org和obj-action，则再检查数据权限
                    if (!flag) {
                        var orgs = e.attr("obj-org");  //元素上通过此属性指示如何获取数据对象的所属组织架构
                        var act = e.attr("obj-action");  //DOM元素上通过此属性指示所需的动作权限
                        if (orgs) {
                            orgs = orgs.split('|');
                            orgs.forEach(function (c) {
                                if (!flag) {
                                    var objOrg = obj[c];
                                    if (objOrg) {
                                        //首先判断用户是否拥有此数据所属组织架构的权限
                                        var aorg = User.AuthedOrgs.findObj("idstr", objOrg);
                                        //如果指定了需要动作权限，则再判断用户在是否拥有动作权限
                                        //TODO：判断用户获得动作权限的岗位所属部门是否高于订单所属部门
                                        if (act && aorg) {
                                            if (User.Authority.findObj("auth", act) != null) {
                                                flag = true;
                                            }
                                        }
                                        else if (aorg) {
                                            flag = true;
                                        }
                                        else {

                                        }
                                    }
                                }
                            })
                        }
                    }


                    //根据检查结果和指定的处理方式
                    if (!flag) {
                        if (!h) {
                            e.remove();
                        }
                        else if (h == 'disable') {
                            e.disable();
                        }
                        else if (h == 'deny') {
                            error("缺少权限", "您无权查看此数据", 5, function () { window.history.go(-1); });
                        }
                        else {
                            e.vl("-");
                        }
                    }
                });


                //检查所有需要特定obj-status的元素，检查结果默认是采取禁用的方式处理
                elm.find("[obj-status]").each(function () {
                    var e = $(this);
                    var ss = e.attr("obj-status").split('|');
                    var sflag = false;
                    ss.forEach(function (s) {
                        if (obj.status == s) {
                            sflag = true;
                        }
                    })
                    if (!sflag) {
                        if (e.attr("execute") == 'disable') {
                            e.disable();
                        }
                        else {
                            e.remove();
                        }
                    }
                })
            },
            pnlAcntInfo: null,
            pnlMyAlerts: null,
        };

        $(function () {

            //解决rem字体导致Chrom下偶尔页面字体变大的问题
            $("body").css("font-size", '1.2rem');

            //加载用户信息
            $.getJSON("/MyBiz/GetUserInfo?tm="+new Date().getTime(), null, View.getUserInfoEnd);

            $(window).on("resize", View.onWndResize);
            $("#pageRight").on("scroll", View.onWndScroll);
            View.onWndResize(null);
            $(window).on("scroll", View.onWndScroll);
            $("#pageHelper").delegate("li", "click", View.onHelp);

            //动态加载更多应用
            var html = "";
            for (var i = 0; i < fullSetting.SubSystems.length; i++) {
                html += "<div class='col-lg-12 mnu_group'>";
                html += "<div class='row mnu_group_title'>";
                html += "<i class='" + fullSetting.SubSystems[i].icon + "'>" + fullSetting.SubSystems[i].Title + "</i>";
                html += "</div>";
                html += "<div class='row mnu_items'>";
                for (var j = 0; j < fullSetting.SubSystems[i].Items.length; j++) {
                    html += "<a class='LinkTo' href='" + fullSetting.SubSystems[i].Items[j].Url + "'>" + fullSetting.SubSystems[i].Items[j].Title + "</a>";
                }
                html += "</div>";
                html += "</div>";
            }
            $("#pvFullMenu").append(html);

            //初始化全部应用菜单
            View.pnlFullMenu = new LiberUI.PopPanel("#pvFullMenu");
            View.pnlFullMenu.PopFor("#allMenu")
                            .option("ShowWay", function (elm) {
                                elm.addClass("active");
                                this.PopFor().addClass("hot");
                            })
                            .option("HideWay", function (elm) {
                                elm.removeClass("active");
                                this.PopFor().removeClass("hot");
                            })
                            .option("AutoPopout", true);


            //初始化用户状态扩展信息面板
            View.pnlAcntInfo = new LiberUI.PopPanel("#pvAcntInfo");
            View.pnlAcntInfo.PopFor("#userHead")
                            .option("ShowWay", function (elm) {
                                elm.addClass("active");
                                this.PopFor().addClass("hot");
                            })
                            .option("HideWay", function (elm) {
                                elm.removeClass("active");
                                this.PopFor().removeClass("hot");
                            })
                            .option("AutoPopout", true);

            View.pnlMyAlerts = new LiberUI.PopPanel("#pvMyAlerts");
            View.pnlMyAlerts.PopFor("#sysAlert")
                            .option("ShowWay", function (elm) {
                                elm.addClass("active");
                                this.PopFor().addClass("hot");
                            })
                            .option("HideWay", function (elm) {
                                elm.removeClass("active");
                                this.PopFor().removeClass("hot");
                            })
                            .option("AutoPopout", true);
        })
    </script>
</body>
</html>
